﻿using UnityEngine;
using System.Collections;

public class JoinIdInput : MonoBehaviour
{
	LoginScene sceneManager;
	
	void Start()
	{
		sceneManager = SceneController.CrrSceneScript as LoginScene;
	}
	
	void OnSelect(bool selected)
	{
		if (selected)
		{
			StartCoroutine( LoginAreaMoveUpCoroutine() );
		}
		else
		{
			StartCoroutine( LoginAreaMoveDownCoroutine() );
		}
	}
	
	IEnumerator LoginAreaMoveUpCoroutine()
	{
		sceneManager.joinAnimation.Play("Login_join_up");
		//yield return new WaitForSeconds(sceneManager.loginAnimation.clip.length);
		sceneManager.isLoginAreaUp = true;
		yield return null;
	}

	IEnumerator LoginAreaMoveDownCoroutine()
	{
		// TODO: 시간 딜레이로 하지 않는 방법으로 바꾸어 줘야 함
		yield return new WaitForSeconds(0.1f);
		
		if (sceneManager.currentMode == LoginScene.LoginMode.Login)
			yield break;

		sceneManager.joinAnimation.Play("Login_join_down");
		//yield return new WaitForSeconds(sceneManager.loginAnimation.clip.length);
		sceneManager.isLoginAreaUp = false;
		yield return null;
	}
}
